#!/usr/bin/env python3

import serial
import time

# Serial port configuration
SERIAL_PORT = 'COM3'
BAUD_RATE = 115200
TIMEOUT = 1

# Test commands to verify case sensitivity
test_commands = [
    'echo "Hello from Test.txt" > Test.txt',
    'echo "Hello from test.txt" > test.txt',
    'ls',
    'cat Test.txt',
    'cat test.txt',
    'rm Test.txt',
    'rm test.txt',
    'ls'
]

def test_case_sensitivity():
    print("Testing filename case sensitivity...")
    
    # Open serial port
    try:
        ser = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=TIMEOUT)
        time.sleep(2)  # Wait for serial port to initialize
        
        # Clear buffer
        ser.read_all()
        
        # Send test commands
        for cmd in test_commands:
            print(f"\nSending: {cmd}")
            ser.write((cmd + '\r\n').encode())
            time.sleep(0.5)
            
            # Read response
            response = ser.read_all().decode()
            print(f"Response:\n{response}")
            
            # Check if command was successful
            if 'Failed' in response or 'Error' in response:
                print(f"Command failed: {cmd}")
                ser.close()
                return False
        
        ser.close()
        print("\nAll tests passed! Filename case sensitivity is working correctly.")
        return True
        
    except Exception as e:
        print(f"Error: {e}")
        return False

if __name__ == "__main__":
    test_case_sensitivity()
